package com.thiswhyme.common.expection;

import com.thiswhyme.common.response.IResponseCode;

import java.text.MessageFormat;

/**
 * @author thiswhyme
 * @date 2022/11/11
 */
public interface BusinessExceptionAssert extends IResponseCode, Assert {

    @Override
    default BusinessException newException() {
        return new BusinessException(this);
    }

    @Override
    default BusinessException newException(Object... args) {
        String msg = MessageFormat.format(this.getMsg(), args);
        return new BusinessException(this.getCode(), msg);
    }

    @Override
    default BusinessException newException(Throwable t, Object... args) {
        String msg = MessageFormat.format(this.getMsg(), args);
        return new BusinessException(this.getCode(), msg, t);
    }
}
